package com.appspot.bugua;




import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;

public class Main extends Activity {
	MP3player player;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        ListView lv= (ListView) findViewById(R.id.mp3List);
        player = MP3player.instance();
        lv.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_expandable_list_item_1,player.contentList()));
        lv.setOnItemClickListener( new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				
				CharSequence fileName= ((TextView)arg1).getText();
				player.play(fileName);
				// TODO Auto-generated method stub
				
			}
		});

    }
    @Override
    protected  void onDestroy(){
    	 super.onDestroy();
    	player.release();
    }
}